 
'Se definen variables globales, direcciones de funciones, variables perennes y direcciones de acceso a recursos
#DEFINE ANCHO 2
#DEFINE ALTO 4
#DEFINE minX 1
#DEFINE maxX 31 
#DEFINE minY 2 
#DEFINE maxY 14 
#DEFINE PANTALLAS_MAX 47 
#DEFINE INIENEM $6ED3
#DEFINE TRANSIT $6F7E
#DEFINE IMPRPANT $6FB7 

#DEFINE BANC_REC 0  
#DEFINE MOD_MEN 1
#DEFINE MOD_INT 3 
#DEFINE MOD_JUE 4  
#DEFINE MOD_MUS 6
#DEFINE MOD_CRY 7
 
#DEFINE DIRVARS $6000 
 
#DEFINE DIRVARSBLK0 $c000 
DIM spaceFnt(95,7) AS UBYTE AT DIRVARSBLK0 

#DEFINE DIRVARSBLK0_PANT DIRVARSBLK0+768  
DIM Pantallas(PANTALLAS_MAX,127) AS UBYTE AT DIRVARSBLK0_PANT  

#DEFINE DIRVARSBLK0_TILES DIRVARSBLK0_PANT+6144  
DIM tiles(63,31) AS UByte AT DIRVARSBLK0_TILES 
DIM tiles_attr(63,3) AS UByte AT DIRVARSBLK0_TILES+2048  

#DEFINE DIRVARSBLK0_SPR_P DIRVARSBLK0_TILES+2304  
DIM Matt_parado_der(2,63) AS UByte AT DIRVARSBLK0_SPR_P  
DIM Matt_parado_der_mask(2,63) AS UByte AT DIRVARSBLK0_SPR_P+192
DIM Matt_saltando_der(1,63) AS UByte AT DIRVARSBLK0_SPR_P+384
DIM Matt_saltando_der_mask(1,63) AS UByte AT DIRVARSBLK0_SPR_P+512
DIM Matt_parado_izq(2,63) AS UByte AT DIRVARSBLK0_SPR_P+512+128
DIM Matt_parado_izq_mask(2,63) AS UByte AT DIRVARSBLK0_SPR_P+512+128+192
DIM Matt_camina_der(1,95) AS UByte AT DIRVARSBLK0_SPR_P+1024   'CAMBIO!!! 3,63 por 3,95
DIM Matt_camina_der_mask(1,95) AS UByte AT DIRVARSBLK0_SPR_P+1024+192 'CAMBIO!!! 3,63 por 3,95
DIM Matt_camina_izq(1,95) AS UByte AT DIRVARSBLK0_SPR_P+1024+2*192 'CAMBIO!!! 3,63 por 3,95
DIM Matt_camina_izq_mask(1,95) AS UByte AT DIRVARSBLK0_SPR_P+1024+3*192 'CAMBIO!!! 3,63 por 3,95
DIM Matt_lars(7) AS UByte AT DIRVARSBLK0_SPR_P+1024+4*192
DIM Matt_saltando_izq(1,63) AS UByte AT DIRVARSBLK0_SPR_P+1792+8
DIM Matt_saltando_izq_mask(1,63) AS UByte AT DIRVARSBLK0_SPR_P+1800+128  
 
DIM Matt_frog_der(47) AS UByte AT DIRVARSBLK0_SPR_P+1800+256  ' 2312
DIM Matt_frog_der_mask(47) AS UByte AT DIRVARSBLK0_SPR_P+1800+256+48
DIM Matt_frog_izq(47) AS UByte AT DIRVARSBLK0_SPR_P+1800+256+96
DIM Matt_frog_izq_mask(47) AS UByte AT DIRVARSBLK0_SPR_P+1800+256+144
DIM Matt_lars2(3,7) AS UByte AT DIRVARSBLK0_SPR_P+1800+256+192
 
#DEFINE DIRVARSBLK0_SPR_PG DIRVARSBLK0_SPR_P+2280 '1800+256+192+32

DIM pg_equipo(31) AS UByte AT DIRVARSBLK0_SPR_PG 
DIM pg_borde(3,7) AS UByte AT DIRVARSBLK0_SPR_PG+32
DIM pg_life(31) AS UByte AT DIRVARSBLK0_SPR_PG+32+32
DIM pg_join(7) AS UByte AT DIRVARSBLK0_SPR_PG+32+32+32
DIM pg_bordepico(3,7) AS UByte AT DIRVARSBLK0_SPR_PG+32+32+32+8
DIM pg_crystal(31) AS UByte AT DIRVARSBLK0_SPR_PG+32+32+32+8+32
 
#DEFINE DIRVARSBLK0_SPR_SS DIRVARSBLK0_SPR_PG+168  
DIM nave_der(127) AS UByte AT DIRVARSBLK0_SPR_SS
DIM nave_izq(127) AS UByte AT DIRVARSBLK0_SPR_SS+128

#DEFINE DIRVARSBLK0_STARS DIRVARSBLK0_SPR_SS+256  
DIM stars(99,1) as UBYTE AT DIRVARSBLK0_STARS
 
#DEFINE DIRVARSBLK0_SPR_E DIRVARSBLK0_STARS+200  
DIM enem(39,31) AS UBYTE AT DIRVARSBLK0_SPR_E  

#DEFINE DIRVARSBLK0_TXT DIRVARSBLK0_SPR_E+1280  
DIM txt AS BYTE AT DIRVARSBLK0_TXT  
 
#DEFINE DIRVARSBLK0_OBJECTS DIRVARSBLK0_TXT+750  
DIM Objets(89,3) AS UByte AT DIRVARSBLK0_OBJECTS  
#DEFINE DIRSDATENEM  DIRVARSBLK0_OBJECTS+(90*4)  

DIM MapaE(47,1,5) AS BYTE AT DIRSDATENEM 
#DEFINE DIRSDATENEM_TIPO  DIRSDATENEM+576 
DIM DatosE(95,4) AS BYTE AT DIRSDATENEM_TIPO 
#DEFINE DIRSDATGATES  DIRSDATENEM_TIPO+(96*5) 
DIM gate(9,2) as UBYTE AT DIRSDATGATES
#DEFINE DIRSDATCOLMASK DIRSDATGATES+30
DIM colMask(1,3) as BYTE AT DIRSDATCOLMASK  
Dim colTmp(2,2,3) As UBYTE AT DIRSDATCOLMASK + 8  

#DEFINE DIRSCONEX $8000-48  
DIM Conex(3,11) AS UBYTE AT DIRSCONEX
#DEFINE DIRSRVISIT $8000-96  
DIM RVisit(47) AS UBYTE AT DIRSRVISIT
 
DIM bP AS UBYTE=20  

'Variables perennes 
DIM MODRun AS UByte AT DIRVARS
DIM TipoControl AS UByte AT DIRVARS + 1  
DIM paneltrn AS UBYTE AT DIRVARS + 2
DIM panelgame AS UBYTE AT DIRVARS + 3
DIM danyofreco2 AS UBYTE AT DIRVARS + 4  
DIM Teclas(4) AS UInteger AT DIRVARS + 5
DIM experience AS UInteger AT DIRVARS + 15  
DIM porc AS UBYTE AT DIRVARS +17   
DIM danyo AS UBYTE AT DIRVARS +18 
DIM ending AS UBYTE AT DIRVARS +19 
DIM jugador AS UBYTE AT DIRVARS +20 
DIM pantalla AS UBYTE AT DIRVARS +21 
DIM CCFail AS UBYTE AT DIRVARS +22 
DIM DatosJ(1,12) AS BYTE AT DIRVARS +23 
DIM nanim AS UBYTE AT DIRVARS +49 
#DEFINE WAITTURNING 30
DIM intro AS UBYTE AT DIRVARS +50
DIM giro(1,1) AS UBYTE AT DIRVARS +51 
DIM energized AS UBYTE AT DIRVARS +55  
DIM reloj AS ULONG AT DIRVARS +56 
DIM anim(20,2) as UBYTE AT DIRVARS +57 +63 

'Función para paginar banco. Extraída del libro de Duefectu 
SUB PaginarMemoria(banco AS UByte)
DIM bankM AS UByte
    bankM = PEEK $5b5c
    bankM = bankM bAND %11111000
bankM = bankM bOR banco
POKE $5b5c,bankM
OUT $7ffd,bankM
END SUB
